import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shopping_group/main/lz_hot_cakes/model/lz_hot_cakes_play_video_model.dart';
import 'package:shopping_group/main/lz_hot_cakes/provider/lz_hot_cakes_provider.dart';
import 'package:shopping_group/res/dimens.dart';

class LzHotCakesAdvertWidget extends StatefulWidget {
  LzHotCakesAdvertWidget({Key key}) : super(key: key);

  @override
  _LzHotCakesAdvertWidgetState createState() => _LzHotCakesAdvertWidgetState();
}

class _LzHotCakesAdvertWidgetState extends State<LzHotCakesAdvertWidget> {
  @override
  Widget build(BuildContext context) {
    return Consumer<LzHotCakesProvider>(builder: (context, value, child) {
      List<String> imageNames = ["icon_total_adver_count", "icon_played_adver_count", "icon_not_played_adver_count"];
      LzHotCakesPlayVideoModel playVideoModel =
          Provider.of<LzHotCakesProvider>(context, listen: false).playVideoModel ?? LzHotCakesPlayVideoModel();
      List<String> title = ["总计广告", "已播广告", "未播广告"];
      List<String> counts = [
        value.ggHadDoCtMap["dsGgAllCt"] ?? "0",
        value.ggHadDoCtMap["dsGgHadDoCt"] ?? "0",
        value.ggHadDoCtMap["dsGgNoDoCt"] ?? "0",
      ];
      //当天看的次数
      List<String> todayCount = [
        playVideoModel.reBuySucCt ?? "0",
        playVideoModel.pushCt ?? "0",
        playVideoModel.senYu ?? "0",
      ];

/**
dsGgAllCt	总次数
dsGgHadDoCt	已看次数
dsGgNoDoCt	剩余次数
 */
      return Container(
        padding: EdgeInsets.symmetric(vertical: 12),
        decoration: BoxDecoration(borderRadius: BorderRadius.circular(5.0), color: Colors.white),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: imageNames.map((imageName) {
            return Container(
              child: Column(
                children: [
                  Container(width: 38, height: 42, child: Image.asset('images/${imageName}.png')),
                  Container(
                    padding: EdgeInsets.only(top: 8),
                    child: Text(title[imageNames.indexOf(imageName)],
                        style: TextStyle(
                            color: Color(0xFF666666), fontSize: Dimens.FONT_SIZE_15, fontWeight: FontWeight.bold)),
                  ),
                  Container(
                    padding: EdgeInsets.only(top: 8),
                    child: Text(
                        counts[imageNames.indexOf(imageName)] + "/${todayCount[imageNames.indexOf(imageName)]}次",
                        style: TextStyle(color: Color(0xFF000000), fontSize: Dimens.FONT_SIZE_12)),
                  ),
                ],
              ),
            );
          }).toList(),
        ),
      );
    });
  }
}
